﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Payton.WP7.Common.Interface;
using System.Collections.Generic;
using Payton.WP7.Common.Configration;
using System.Collections;
using Payton.WP7.Common;
using System.Windows.Media.Imaging;

namespace Payton.WP7.Common.Model
{
    public abstract class SNSProvider
    {
        protected AccountManager AccountManager { get; private set; }

        public SNSProvider()
        {
            Initialize();
        }

        protected virtual void Initialize()
        {
            this.Type = SNSProviderType.Unknow;
            AccountManager = AccountManager.Current;
        }

        public OAuthSettings AuthSettings
        {
            get
            {
                return GetAuthSettings();
            }
        }

        public string ProviderName
        {
            get;
            set;
        }

        protected SNSProviderType type;
        public SNSProviderType Type
        {
            get { return type; }
            set { type = value; }
        }

        public T GetSerivce<T>() where T : IServiceFactory, new()
        {
            //return ;
            return new T();
        }

        public BitmapImage IconImage
        {
            get
            {
                var uri = GetIconUrl();
                if (uri != null)
                    return new BitmapImage(uri);
                else
                    return null;
            }
        }

        public IOAuthService AuthriozeService
        {
            get
            {
                return GetAuthriozeService();
            }
        }

        protected abstract IOAuthService GetAuthriozeService();

        protected abstract OAuthSettings GetAuthSettings();

        internal abstract SNSAccount NewAccount();

        internal abstract Uri GetIconUrl();

        public abstract bool IsSupported
        {
            get;
        }
     
    }


}
